//
//  ZXFDXuanZeZiYuanTopView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/22.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "ZXFDXuanZeZiYuanTopView.h"

@implementation ZXFDXuanZeZiYuanTopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    self.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:self.titleLbael];
    [self addSubview:self.statusLabel];
    [self addSubview:self.startTimeLabel];
    [self addSubview:self.startTime];
    [self addSubview:self.startLineView];
    
    [self addSubview:self.endTimeLabel];
    [self addSubview:self.endTime];
    [self addSubview:self.endLineView];
    [self addSubview:self.topShowView];
    
}
- (void)layout{
    [_titleLbael mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(@20);
        make.height.equalTo(@15);
        make.width.equalTo(@150);
    }];
    [_statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_titleLbael.mas_right).offset(10);
        make.centerY.equalTo(self->_titleLbael.mas_centerY);
        make.height.equalTo(@15);
        make.width.equalTo(@50);
    }];
    
    [_startTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@70);
        make.top.equalTo(self->_titleLbael.mas_bottom).offset(20);
        make.width.equalTo(@80);
        make.height.equalTo(@15);
    }];
    [_startTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_startTimeLabel.mas_right).offset(10);
        make.centerY.equalTo(self->_startTimeLabel.mas_centerY);
        make.width.equalTo(@120);
        make.height.equalTo(@15);
    }];
    [_startLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_startTime.mas_left);
        make.top.equalTo(self->_startTime.mas_bottom);
        make.width.equalTo(@120);
        make.height.equalTo(@1);
    }];
    
    [_endTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-70-120-80);
        make.centerY.equalTo(self->_startTimeLabel.mas_centerY);
        make.width.equalTo(@80);
        make.height.equalTo(@15);
    }];
    [_endTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_endTimeLabel.mas_right).offset(10);
        make.centerY.equalTo(self->_endTimeLabel.mas_centerY);
        make.width.equalTo(@120);
        make.height.equalTo(@15);
    }];
    [_endLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_endTime.mas_left);
        make.top.equalTo(self->_endTime.mas_bottom);
        make.width.equalTo(@120);
        make.height.equalTo(@1);
    }];
    [_topShowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.top.equalTo(@100);
        make.right.equalTo(@0);
        make.height.equalTo(@50);
    }];
}
- (UILabel *)titleLbael{
    if (!_titleLbael) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        NSString *className = GetDataFromNSUserDefaults(@"banjimingcheng");
        label.text = className;
        label.textColor = TITLECOLOR;
        _titleLbael = label;
    }
    return _titleLbael;
}

//SaveDataToNSUserDefaults(self->_selectedZhuJiaoView.nameLabel.text, @"banjimingcheng");
//SaveDataToNSUserDefaults(self->beginDate, @"kaishishijian");
//SaveDataToNSUserDefaults(self->endDate, @"jieshushijian");

- (UILabel *)statusLabel{
    if (!_statusLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:12];
        label.text = @"进行中";
        label.textColor = [UIColorChange colorwithHexString:@"#FF4800"];
        _statusLabel = label;
    }
    return _statusLabel;
}
- (UILabel *)startTimeLabel{
    if (!_startTimeLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:14];
        label.text = @"开始日期：";
        label.textColor = TITLECOLOR;
        _startTimeLabel = label;
    }
    return _startTimeLabel;
}
- (UILabel *)startTime{
    if (!_startTime) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:12];
        NSString *className = GetDataFromNSUserDefaults(@"kaishishijian");
        label.text = className;
        label.textColor = TITLECOLOR;
        _startTime = label;
    }
    return _startTime;
}
- (UIView *)startLineView{
    if (!_startLineView) {
        UIView *label = [[UIView alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.backgroundColor = LINCOLOR;
        _startLineView = label;
    }
    return _startLineView;
}
- (UILabel *)endTimeLabel{
    if (!_endTimeLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:14];
        label.text = @"结束日期：";
        label.textColor = TITLECOLOR;
        _endTimeLabel = label;
    }
    return _endTimeLabel;
}
- (UILabel *)endTime{
    if (!_endTime) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:12];
        NSString *className = GetDataFromNSUserDefaults(@"jieshushijian");
        label.text = className;
        label.textColor = TITLECOLOR;
        _endTime = label;
    }
    return _endTime;
}
- (UIView *)endLineView{
    if (!_endLineView) {
        UIView *label = [[UIView alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.backgroundColor = LINCOLOR;
        _endLineView = label;
    }
    return _endLineView;
}
- (ZXFDXZZYTopShowView *)topShowView{
    if (!_topShowView) {
        _topShowView = [[ZXFDXZZYTopShowView alloc]initWithFrame:CGRectMake(0, 100, self.frame.size.width, 50)];
        _topShowView.backgroundColor = MAINBACKCOLOR;
    }
    return _topShowView;
}
@end
